#include "TextureSample.h"
#include "DirectXTK\WICTextureLoader.h"
#include "Game.h"
TextureSample::TextureSample(ID3D11Device* device, ID3D11DeviceContext* context)
	: SampleBase(device,context),radians(0.0f)
{
	// create Primitive
	m_Sphere = GeometricPrimitive::CreateSphere(context);

	// create Texture
	ThrowIfFailed(
		CreateWICTextureFromFile(device, L"../Resources/Textures/Earth.jpg", nullptr,
			m_texture.ReleaseAndGetAddressOf()));
	// MVP
	m_world = Matrix::Identity;
	m_view = Matrix::CreateLookAt(Vector3(2.f, 0.f, 2.f),
		Vector3::Zero, Vector3::UnitY);
	m_proj = Matrix::CreatePerspectiveFieldOfView(XM_PI / 4.f,
		16.0f / 9.0f, 0.1f, 10.f);
}

TextureSample::~TextureSample()
{

}

void TextureSample::Update(float dt)
{
	radians += dt;
	if (radians > XM_2PI)
	{
		dt = 0.0f;
	}
	m_world = Matrix::CreateRotationY(radians);
}

void TextureSample::Render()
{
	m_Sphere->Draw(m_world, m_view, m_proj, Colors::White, m_texture.Get());
}

void TextureSample::GUI()
{
	ImGui::Begin("Texture");
	ImGui::Image((void*)m_texture.Get(), ImVec2(256, 128));
	ImGui::End();
}

void TextureSample::DrawFont()
{

}
